import _appTest
import unittest
import PikaStdLib
import time
import network,socket,json



print('hello pikapython!')
print('sd load app!')
print('go go go again!')

c = _appTest.testadd(5,8)
print('add autotest!',c)

mem = PikaStdLib.MemChecker()
print('mem.max():')
mem.max()
print('mem.now():')
mem.now()

def wifi_init():
    # wifi模块分为AP和STA，AP是被动连接(路由器)，STA是主动连接(手机、笔记本等)
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    # wifi账号和密码
    wlan.connect('XZY_wifi', 'xiaozhiyi99.com')
    for i in range(10):
        if wlan.isconnected():
            print('wifi connected')
            return
        time.sleep(1)
        print('wifi is connecting...',i)

def socket_connect():
    wifi_init()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(('192.168.99.158', 9527))
    print("socket connected")
    # s.send('hello'.encode())
    return s










